<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
--%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>挂靠公司详细信息</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <script type="text/javascript" src="<%=path %>/resource/lib/plugins/ajaxfileupload.js"></script>
</head>
<!-- 是否显示三方数据页签 -->
<sys:funcAuth resCd="ThreeData">
    <span id="isShowThreeDataPage" />
</sys:funcAuth>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div tabid="tabA" title="基本信息" id="tabAId">
            <form id="prj_lnk_comp_form">
                <div class="fieldset1 tabel_col clearFix">
                	<div class="caption">
	                    <div class="btnsBox posR">
	                    	<%-- <c:if test="${isShowYJDQQYXXBtn ==1 }"> --%>
		                        <%-- <input name="YJDQQYXXBtn" id="YJDQQYXXBtn" class="sq-button sq-button-round" 
		                        onclick="readInfo()">一键读取企业信息</span> --%>
	                    	<%-- </c:if> --%>
	                    </div>
	                    <span>&nbsp;</span>
	                </div>
                	
                    <div class="fieldBox col_50">
                        <div class="label">公司名称</div>
                        <div class="field">
                            <input name="lnkCompNm" id="lnkCompNm" type="text" class="ui-textbox" 
                            	<c:if test="${isLnkNmModify == 0 }">disabled="disabled"</c:if>
                                   value="${prjLnkComp.lnkCompNm }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">统一社会信用代码</div>
                        <div class="field">
                            <input name="succ" id="succ" type="text" class="ui-textbox"
                                   value="${prjLnkComp.succ}" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" style="display: none;">
                        <div class="label">组织机构代码</div>
                        <div class="field">
                            <input name="orgCode" id="orgCode" type="text" class="ui-textbox" readonly="readonly"
                                   value="${prjLnkComp.orgCode}" >
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>

                    <div class="fieldBox col_50">
                        <div class="label">公司归属</div>
                        <div class="field">
                            <select name="ownerCd" id="ownerCd">
                                <c:forEach items="${keyValueList}" var="opt">
                                    <option value="${opt.key}"
                                            <c:if test="${opt.key==prjLnkComp.ownerCd }">selected="selected"</c:if>
                                    >${opt.value}</option>
                                </c:forEach>
                            </select>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">所在地</div>
                        <div class="field">
                            <input name="officeAddr" id="officeAddr" type="text" isShow="iscar" class="ui-textbox"
                                   value="${prjLnkComp.officeAddr }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">主营项目类别</div>
                        <div class="field">
                            <input name="majorBiz" id="majorBiz" type="text" class="ui-textbox"
                                   value="${prjLnkComp.majorBiz }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">企业类型</div>
                        <div class="field">
                            <input name="compTyp" id="compTyp" type="text" class="ui-textbox" disabled="disabled"
                                   value="${prjLnkComp.compTyp }">
                        </div>
                    </div>
                    <div class="fieldBox col_50" style="display: none;">
                        <div class="label">营业执照注册号</div>
                        <div class="field">
                            <input name="bizLicNo" id="bizLicNo" type="text" class="ui-textbox"
                                   readonly="readonly" value="${prjLnkComp.bizLicNo }" ><!--  isShow="isother" -->
                            <span class="requiredSymbol" isShow="isother">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">注册地址</div>
                        <div class="field">
                            <input name="regAddr" id="regAddr" type="text" class="ui-textbox" disabled="disabled"
                                   value="${prjLnkComp.regAddr }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">成立日期</div>
                        <div class="field">
                            <input name="regDt" id="regDt" type="text" isShow="iscar" class="ui-datepicker"
                                   disabled="disabled"
                                   value="${prjLnkComp.regDtStr }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" style="display: none;">
                        <div class="label">税务登记号</div>
                        <div class="field">
                            <input name="taxRegNo" id="taxRegNo" type="text" class="ui-textbox" readonly="readonly"
                                   value="${prjLnkComp.taxRegNo }" >
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">道路运输许可证有效期</div>
                        <div class="field">
                            <input name="expDt" id="expDt" type="text" isShow="iscar" class="ui-datepicker"
                                   value="${prjLnkComp.expDtStr }" <%--validate="{required:true}"--%>>
                            <%--<span class="requiredSymbol" isShow="isother">*</span>--%>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">经营范围</div>
                        <div class="field">
                            <input name="bizScope" id="bizScope" type="text" class="ui-textbox" disabled="disabled"
                                   value="${prjLnkComp.bizScope }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label"> 法人代表</div>
                        <div class="field">
                            <input name="corpRep" id="corpRep" type="text" isShow="iscar" class="ui-textbox"
                                   value="${prjLnkComp.corpRep }" disabled="disabled">
                            <span class="requiredSymbol" isShow="iscar">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">法人身份证号</div>
                        <div class="field">
                            <input name="idNo" id="idNo" type="text" class="ui-textbox"
                                   disabled="disabled" value="${prjLnkComp.idNo }">
                        </div>
                    </div>

                    <div class="fieldBox col_50">
                        <div class="label">现累计挂靠数量</div>
                        <div class="field">
                            <input name="totLnkQty" id="totLnkQty" type="text" class="ui-textbox"
                                   value="${prjLnkComp.totLnkQty }" disabled="disabled">
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">自有车辆备案数量</div>
                        <div class="field">
                            <input name="ownQty" id="ownQty" type="text" class="ui-textbox"
                                   value="${prjLnkComp.ownQty }" disabled="disabled">
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">在我司累积挂靠车辆</div>
                        <div class="field">
                            <input name="ourTotLnkQyt" id="ourTotLnkQyt" type="text" class="ui-textbox"
                                   value="${prjLnkComp.ourTotLnkQyt }" disabled="disabled">
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">可支持挂靠项目类型</div>
                        <div class="field">
                            <input name="suppLnkPrjTypCd" id="suppLnkPrjTypCd" type="text" ltype="combobox" validate="{required:true}"><span
                                class="requiredSymbol">*</span>
                        </div>
                    </div>
                     <div class="fieldBox col_50">
						<div class="label">三方授权书是否提供</div>
						<div class="field">
	                        <select name="isUploadLoa" id="isUploadLoa" data-value=" " validate ="{required:true,select:true}">
	                        	<option value=" " checked >请选择</option>
	                        	<option value="1">是</option>
	                        	<option value="0">否</option>
								
							</select>
	                    </div>
					</div>
					<div class="fieldBox col_50">
					<div class="label">三方授权书是否回收</div>
						<div class="field">
	                        <select name="isRecycleLoa" id="isRecycleLoa" data-value=" " validate ="{required:true,select:true}">
	                        	<option value=" " checked >请选择</option>
	                        	<option value="1">是</option>
	                        	<option value="0">否</option>
								
							</select>
	                    </div>
					</div>
                    <div class="fieldBox col_66_auto">
								<div class="label">区域</div>
								<div class="field">
									<!-- <input name="rgnPrCd" id="rgnPrCd" type="text" class="ui-textbox" value=""> -->
									<jsp:include page="../../system/sysRegion/region.jsp"
										flush="true">
										<jsp:param name="regionShowLvl" value="2" />
									</jsp:include>
									<span class="requiredSymbol">*</span>
								</div>
					</div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">实际控制人</div>
                        <div class="field">
                            <input name="actCtrlNm" id="actCtrlNm" type="text" class="ui-textbox" disabled="disabled"
                                   value="${prjLnkComp.actCtrlNm}" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">实际控制人手机号码</div>
                        <div class="field">
                            <input name="actCtrlMp" id="actCtrlMp" type="text" class="ui-textbox" disabled="disabled"
                                   value="${prjLnkComp.actCtrlMp }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">联系人</div>
                        <div class="field">
                            <input name="lnkNm" id="lnkNm" type="text" class="ui-textbox"
                                   disabled="disabled" value="${prjLnkComp.lnkNm }">
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">联系人手机号码</div>
                        <div class="field">
                            <input name="lnkMp" id="lnkMp" type="text" isShow="iscar" class="ui-textbox"
                                   value="${prjLnkComp.lnkMp }" disabled="disabled">
                            <span class="requiredSymbol" isShow="iscar">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label"> 联系人职务</div>
                        <div class="field">
                            <input name="lnkPost" id="lnkPost" type="text" class="ui-textbox"
                                   value="${prjLnkComp.lnkPost }" disabled="disabled">
                        </div>
                    </div>
                    <div class="fieldBox col_100">
                        <div class="label">备注</div>
                        <div class="field">
                            <textarea name="rem" id="rem" rows="4" class="ui-textarea l-textarea" style="width:80%"
                                      value="" disabled="disabled">${prjLnkComp.rem } </textarea>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">渠道担保业务类型</div>
                        <div class="field">
                            <input name="propCd" id="propCd" type="text" ltype="combobox" disabled="disabled">
                        </div>
                    </div>
                    <div class="fieldBox col_100_auto">
                        <div class="label">渠道担保协议有效期</div>
                        <div class="field">
                            <input width="20px" name="validTmStar" id="validTmStar" value="${prjLnkComp.validTmStar }" type="text" class="ui-datepicker"  disabled="disabled">
                            -
                            <input width="20px" name="validTmEnd" id="validTmEnd" value="${prjLnkComp.validTmEnd }" type="text" class="ui-datepicker" disabled="disabled">
                        </div>
                    </div>
                    <div class="fieldBox col_66">
                        <div class="label">公路车【首期】比例</div>
                        <div class="field" style="width: 100%;">
                            <input name="roadBicycleRate" id="roadBicycleRate" value="${prjLnkComp.roadBicycleRate }"  type="text" class="ui-textbox" validate="{number:true}" disabled="disabled"><span>%</span>
                        </div>
                    </div>
                    <div class="fieldBox col_66">
                        <div class="label">工程车【首期】比例</div>
                        <div class="field" style="width: 100%;">
                            <input name="stopTruckRate" id="stopTruckRate" type="text" value="${prjLnkComp.stopTruckRate }" class="ui-textbox" validate="{number:true}"disabled="disabled"><span>%</span>
                        </div>
                    </div>
                    <div class="fieldset1 tabel_col tabel_col_s clearFix">
                        <div class="sqPanel_body">
                            <div id="propFileCfgGrid" class="sq-grid"></div>
                        </div>
                    </div>
                </div>
                <div class="fieldBox col_100" style="display:none;">
                    <div class="field">
                        <input name="lnkCompId" id="lnkCompId" type="text" class="ui-textbox" value="${prjLnkComp.id }">
                    </div>
                </div>
                <div class="fieldBox col_100" id="psnDiv" style="display:none">
                    <div class="sqPanel">
                        <div class="sqPanel_head inL">
                            <%--<div class="btnsBox inLC">
                                <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round">添加</span>
                            </div>
                            <div class="btnsBox posR">
		                        <!-- <span id="YJDQGGXXBtn" class="sq-button sq-button-round" onclick="readManagerInfo()">一键读取高管信息</span> -->
		                        <input id="YJDQGGXXBtn" class="sq-button sq-button-round" onclick="readManagerInfo()" value="一键读取高管信息"/>
		                    </div>--%>
                            
                            <span>主要人员信息</span>
                        </div>
                        <br/>
                        <br/>
                        <div id="psnGrid">
                            <div id="ligergrid_psn" class="sq-grid"></div>
                        </div>
                    </div>
                </div>
                <div class="fieldset1 tabel_col tabel_col_s clearFix">
                    <div class="caption">
                        <span class="title">上传附件信息 </span>
                    </div>
                    <div class="sqPanel_body">
                        <div id="lnkFileInfoCfgGrid" class="sq-grid"></div>
                    </div>
                    <%--<div class="fieldBox col_100" id="fileDetail">
                        <div class="label">资料上传</div>
                        <div class="field">
                            <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true">
                                <jsp:param name="filePath" value="lnkcomp"/>
                            </jsp:include>
                            <input name="lnkCompId" id="lnkCompId" type="hidden" class="ui-textbox"
                                   value="${prjLnkComp.id }">
                        </div>
                    </div>

                    <div class="fieldBox col_100" id="fileModify">
                        <div class="label">资料</div>
                        <div class="field">
                            <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList.jsp" flush="true">
                                <jsp:param name="pkId" value="${prjLnkComp.id }"/>
                                <jsp:param name="tabNm" value="PRJ_LNK_COMP"/>
                            </jsp:include>
                        </div>
                    </div>--%>
                </div>

                <div class="btnsBox">
                    <span id="prj_lnk_comp_add_btn_id" class="sq-button sq-button-round" onclick="save();"><!-- <i class="sqBtnIco_10"></i> -->保存</span>
                    <span id="prj_lnk_comp__cancel_btn_id" class="sq-button sq-button-round" onclick="cancelBtn();"><!-- <i class="sqBtnIco_14"></i> -->取消</span>
                    <c:if test="${not empty isOrSubmit and isOrSubmit == '1'}">
                        <span id="prj_lnk_comp_submit_btn_id" class="sq-button sq-button-round" onclick="submitAndStartFlow();"><!-- <i class="sqBtnIco_14"></i> -->提交</span>
                    </c:if>

                    <span id="relationships" onclick="relationshipsView()"
                                  class="sq-button sq-button-round">集团关联图谱</span>

                </div>
            </form>
        </div>
        <div tabid="tabB" title="相关项目" id="tabBId">
            <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
        </div>
        <div tabid="tabC" title="备案账号" id="tabCId">
            <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
        </div>
        <div tabid="tabD" title="敞口历史" id="tabDId">
            <iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
        </div>
        <div tabid="tabE" title="人工干预" id="tabEId">
            <iframe frameborder="0" name="tabE" id="tabE" src=""></iframe>
        </div>
        <div tabid="tabG" title="附件资料">
            <iframe src="" frameborder="0" name="tabG" id="tabG"></iframe>
        </div>
        <div tabid="tabF" title="三方数据">
            <iframe frameborder="0" name="tabF" id="tabF" src=""></iframe>
        </div>
    </div>
</div>
</div>

	<!-- 操作原因 -->
	<form id="reasonFromSet" style="display:none;">
		<div class="field">
			<textarea name="reason" id="reason" class="ui-textarea l-textarea" style="width:360px;height: 150px;"></textarea>
		</div>
	</form>

<script type="text/javascript">


	var LinkCrAmt = '${LinkCrAmt}';
    var BuOrgCd = '${BuOrgCd}';
    var audStsCd = '${audStsCd}';
    var importDataSource = '${importDataSource}';
    var rlPsnGrid;
    var rlPsnList = null;
    var isFlow = '${isFlow}';
    if ('${rlPsnList}') {
        rlPsnList =${rlPsnList};
    }
    var certTypCdList =${certTypCdList};
    var rlRsnTypListJSON =${rlRsnTypListJSON};
    var rlRsnTypList = [];
    if ('${rlRsnTypList}') {
        rlRsnTypList = JSON.parse('${rlRsnTypList}');
    }
    var propFileCfgGrid = null;//挂靠公司资料配置明细
  	//默认必填项
    var mustAddRlPsnJSON = [];
    if ('${mustAddRlPsnTypCdJSON}') {
        mustAddRlPsnJSON = JSON.parse('${mustAddRlPsnTypCdJSON}');
    }
    //默认非必填项
    var noAddRlPsnJSON = [];
    if ('${noAddRlPsnTypCdJSON}') {
        noAddRlPsnJSON = ${noAddRlPsnTypCdJSON};
    }
    var pageInApp = {
        flag: true
    };
    var fromSrcBiz = '${fromSrcBiz}';
    var isOrSubmit = '${isOrSubmit}';
    var lnkFileInfoCfgGrid = null;//挂靠公司资料配置明细
    var upload_result_params = [];
    var serverPrefixPath = "";

    var isCheckVerify = '${isCheckVerify}';

    //默认归属第三方
    var _cfgSysCd = '${cfgSysCd2}'; //附件系统CODE
    var _cfgOrgCd = '${cfgOrgCd2}'; //附件组织架构
    var _tabNm = '${tabNm2}'; //附件对应表
    var _cfgCd = '${cfgCd2}'; //附件CODE
    var _modulePath = '${modulePath2}';
    var _costomerPath = '${costomerPath2}';
    var _rootPath = '${rootPath2}';
    var _uploadSysCd = '${uploadSysCd2}';

    //当挂靠公司ID不为空且归属为自有
    if (StringUtils.isNotEmpty($("#lnkCompId").val())) {
        if (1 == $("#ownerCd").val()) {
            _cfgSysCd = '${cfgSysCd1}'; //附件系统CODE
            _cfgOrgCd = '${cfgOrgCd1}'; //附件组织架构
            _tabNm = '${tabNm1}'; //附件对应表
            _cfgCd = '${cfgCd1}'; //附件CODE
            _modulePath = '${modulePath1}';
            _costomerPath = '${costomerPath1}';
            _rootPath = '${rootPath1}';
            _uploadSysCd = '${uploadSysCd1}';
        } else if (3 == $("#ownerCd").val()) {
            _cfgSysCd = '${cfgSysCd3}'; //附件系统CODE
            _cfgOrgCd = '${cfgOrgCd3}'; //附件组织架构
            _tabNm = '${tabNm3}'; //附件对应表
            _cfgCd = '${cfgCd3}'; //附件CODE
            _modulePath = '${modulePath3}';
            _costomerPath = '${costomerPath3}';
            _rootPath = '${rootPath3}';
            _uploadSysCd = '${uploadSysCd3}';
        }
    }

    var allCfgDtlCdList = [];
    if ('${allCfgDtlCdList}') {
        allCfgDtlCdList = JSON.parse('${allCfgDtlCdList}');
    }

    $(function () {
    	
        initStyle();

        initData();
        var lnkCompId = $("#lnkCompId").val();
        /*if (BuOrgCd == "00000005") {
            initRlPsnCarGrid(rlPsnList);
        } else {
            initRlPsnGrid(rlPsnList);
        }*/
        initRlPsnGrid();

        lnkFileInfoCfgGrid = $("#lnkFileInfoCfgGrid").ligerGrid({
            url: '<%=path%>/project/prjlnkcomp/initLnkFileInfoList.do?pkId='+lnkCompId+'&cfgCd='+_cfgCd +'&tabNm='+_tabNm +"&cfgSysCd="+_cfgSysCd+'&cfgOrgCd='+_cfgOrgCd+'&uploadSysCd='+_uploadSysCd,
            method: 'get',
            columns: [
                {display: '资料名称', name: 'datNm',align: 'left', minWidth: 100, enabledSort: false,
                    render:function (rowdata, rowindex, value) {
                        var mustSymbol = '<span class="requiredSymbol">*</span>';
                        if (rowdata.isMust == 1) {
                            return value + mustSymbol;
                        } else {
                            return value;
                        }
                    }
                },
                {display: '上传文件名称', name: 'fileNm',align: 'left', minWidth: 100, enabledSort: false,
                    render:function(rowdata,rowindex,value){
                        if(value){
                            var h;
                            h='<a href="javascript:uploadFileByUrl(';
                            h+="'"+rowdata.filePath+"'";
                            h+=",'"+rowdata.fileNm+"'";
                            h+=')">'+rowdata.fileNm+'</a>'
                            return h;
                        }
                    }
                },
                {display: '上传文件路径', name: 'filePath',align: 'left', minWidth: 100,hide:true},
                {display: '上传文件明细', name: 'cfgDtlCd',align: 'left', minWidth: 100,hide:true},
                {display: '上传时间', name: 'crtTm',align: 'left', minWidth: 100, enabledSort: false,render:renderDate},
                {display: '状态', name: 'audStsCdNm', width: 100, enabledSort: false},
                {display: '操作', name: '', minWidth: 200,align: 'left',  enabledSort: false,
                    render:function(rowdata,rowindex,value){
                        var h='';
                        if(rowdata.audStsCd){
                            if(rowdata.audStsCd !=1){
                                if(!isCheckVerify || isCheckVerify != 1 ){
                                    /*if(rowdata.fileId) {
                                        h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="delFile(event,' + rowdata.fileId + ');"><i class="sqBtnIco_7"></i>删除</a>';
                                    }else{
                                        h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="delUpLoadindFile(event,' + rowindex +','+rowdata.cfgDtlCd+');"><i class="sqBtnIco_7"></i>删除</a>';
                                    }*/
                                }else{
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',1);"><i class="sqBtnIco_15"></i>验证通过</a>';
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',2);"><i class="sqBtnIco_14"></i>验证不通过</a>';
                                }
                            }else{
                                if (isCheckVerify && isCheckVerify == 1) {
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',1);"><i class="sqBtnIco_15"></i>验证通过</a>';
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',2);"><i class="sqBtnIco_14"></i>验证不通过</a>';
                                }
                            }
                        }else{
                            //h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="delUpLoadindFile(event,' + rowindex + ','+rowdata.cfgDtlCd+');"><i class="sqBtnIco_7"></i>删除</a>';
                        }
                        return h;
                    }
                },
                {display: '上传', name: 'uploadNm', width: 80,align: 'left', enabledSort: false,
                    render:function(rowdata,rowindex,value){
                        var h='';
                        if(audStsCd && audStsCd != 1){
                            if(rowdata.fileId){
                                if(rowdata.audStsCd && rowdata.audStsCd !=1){
                                    h+='<span class="sq-button sq-button-round fileupload-button">上传<input type="file" id="fileup_'+_cfgCd+'_'+rowdata.cfgDtlCd+'" multiple name="fileup_'+_cfgCd+'_'+rowdata.cfgDtlCd+'"' +
                                        ' class="fileupload-input" onchange="onChangefile_multi(event,\''+_cfgCd+'\',\''+rowdata.cfgDtlCd+'\',\''+_cfgOrgCd+'\')"></span>';
                                }else {//if(!rowdata.audStsCd){
                                    h+='<span class="sq-button sq-button-round fileupload-button">上传<input type="file" id="fileup_'+_cfgCd+'_'+rowdata.cfgDtlCd+'" multiple name="fileup_'+_cfgCd+'_'+rowdata.cfgDtlCd+'"' +
                                        ' class="fileupload-input" onchange="onChangefile_multi(event,\''+_cfgCd+'\',\''+rowdata.cfgDtlCd+'\',\''+_cfgOrgCd+'\')"></span>';
                                }
                            }else{
                                h+='<span class="sq-button sq-button-round fileupload-button">上传<input type="file" id="fileup_'+_cfgCd+'_'+rowdata.cfgDtlCd+'" multiple name="fileup_'+_cfgCd+'_'+rowdata.cfgDtlCd+'"' +
                                    ' class="fileupload-input" onchange="onChangefile_multi(event,\''+_cfgCd+'\',\''+rowdata.cfgDtlCd+'\',\''+_cfgOrgCd+'\')"></span>';
                            }
                        }

                        /*if(!rowdata.fileId || (!rowdata.audStsCd || rowdata.audStsCd !=1) || (audStsCd && audStsCd !=1)){
                            h+='<span class="sq-button sq-button-round fileupload-button">上传<input type="file" id="fileup_'+rowdata.cfgCd+'_'+rowdata.cfgDtlCd+'" multiple name="fileup_'+rowdata.cfgCd+'_'+rowdata.cfgDtlCd+'"' +
                                ' class="fileupload-input" onchange="onChangefile_multi(event,\''+rowdata.cfgCd+'\',\''+rowdata.cfgDtlCd+'\',\''+rowdata.orgCd+'\',\''+rowdata.fileId+'\',\''+rowindex+'\')"></span>';
                        }*/
                        return h;
                    }
                },
            ],
            root: 'rows',
            hideLoadButton : true,
            width: '100%',
            height: '100%',
            isScroll: false,
            rownumbers:true,  //显示序号
            checkbox: false,
            allowUnSelectRow:true,
            alternatingRow: false,
            frozen: false,
            usePager: false,
            onAfterShowData: function ()
            {
                $('#lnkFileInfoCfgGrid').rowspan('datNm');
                $('#lnkFileInfoCfgGrid').rowspan('uploadNm');
            },
            onSuccess : function(data,grid){
                upload_result_params = [];
                var uploadJOSN = JSON.parse(JSON.stringify(data.rows));
                console.log("uploadJOSN =s= " + JSON.stringify(uploadJOSN));
                for (var i=0; i< uploadJOSN.length; i++){
                    if (StringUtils.isNotEmpty(uploadJOSN[i].fileNm)) {
                        upload_result_params.push(uploadJOSN[i]);
                    }
                }
                console.log("upload_result_params =s= " + JSON.stringify(upload_result_params));

            },
        });
        propFileCfgGrid = $("#propFileCfgGrid").ligerGrid({
            url: '<%=path%>/project/prjlnkcomp/initPropFileList.do?cfgCd='+_propCfgCd +'&tabNm='+_propTabNm +"&cfgSysCd="+_propCfgSysCd+'&cfgOrgCd='+_propCfgOrgCd+'&uploadSysCd='+_propUploadSysCd,
            parms:{pkId:lnkCompId},
            method: 'get',
            columns: [
                {display: '资料名称', name: 'datNm',align: 'left', minWidth: 100, enabledSort: false,
                    render:function (rowdata, rowindex, value) {
                        var mustSymbol = '<span class="requiredSymbol">*</span>';
                        if (rowdata.isMust == 1) {
                            return value + mustSymbol;
                        } else {
                            return value;
                        }
                    }
                },
                {display: '上传文件名称', name: 'fileNm',align: 'left', minWidth: 100, enabledSort: false,
                    render:function(rowdata,rowindex,value){
                        if(value){
                            var h;
                            h='<a href="javascript:uploadFileByUrl(';
                            h+="'"+rowdata.filePath+"'";
                            h+=",'"+rowdata.fileNm+"'";
                            h+=')">'+rowdata.fileNm+'</a>'
                            return h;
                        }
                    }
                },
                {display: '上传文件路径', name: 'filePath',align: 'left', minWidth: 100,hide:true},
                {display: '上传文件明细', name: 'cfgDtlCd',align: 'left', minWidth: 100,hide:true},
                {display: '上传时间', name: 'crtTm',align: 'left', minWidth: 100, enabledSort: false,render:renderDate},
                {display: '状态', name: 'audStsCdNm', width: 100, enabledSort: false},
                {display: '操作', name: '', minWidth: 200,align: 'left',  enabledSort: false,
                    render:function(rowdata,rowindex,value){
                        var h='';
                        if(rowdata.audStsCd){
                            if(rowdata.audStsCd !=1){
                                if(!isCheckVerify || isCheckVerify != 1 ){
                                    /*if(rowdata.fileId) {
                                        h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="delFile(event,' + rowdata.fileId + ');"><i class="sqBtnIco_7"></i>删除</a>';
                                    }else{
                                        h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="delUpLoadindFile(event,' + rowindex +','+rowdata.cfgDtlCd+');"><i class="sqBtnIco_7"></i>删除</a>';
                                    }*/
                                }else{
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',1);"><i class="sqBtnIco_15"></i>验证通过</a>';
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',2);"><i class="sqBtnIco_14"></i>验证不通过</a>';
                                }
                            }else{
                                if (isCheckVerify && isCheckVerify == 1) {
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',1);"><i class="sqBtnIco_15"></i>验证通过</a>';
                                    h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="modifyAudStsCd(event,' + rowdata.fileId + ',2);"><i class="sqBtnIco_14"></i>验证不通过</a>';
                                }
                            }
                        }else{
                            //h += '<a class="sq-button-hasicon" style="cursor:pointer;" onclick="delUpLoadindFile(event,' + rowindex + ','+rowdata.cfgDtlCd+');"><i class="sqBtnIco_7"></i>删除</a>';
                        }
                        return h;
                    }
                },
            ],
            root: 'rows',
            hideLoadButton : true,
            width: '100%',
            height: '100%',
            isScroll: false,
            rownumbers:true,  //显示序号
            checkbox: false,
            allowUnSelectRow:true,
            alternatingRow: false,
            frozen: false,
            usePager: false,
            onAfterShowData: function ()
            {
                $('#propFileCfgGrid').rowspan('datNm');
                $('#propFileCfgGrid').rowspan('uploadNm');
            },
            onSuccess : function(data,grid){
                upload_result_params2 = [];
                var uploadJOSN = JSON.parse(JSON.stringify(data.rows));
                console.log("uploadJOSN =s= " + JSON.stringify(uploadJOSN));
                for (var i=0; i< uploadJOSN.length; i++){
                    if (StringUtils.isNotEmpty(uploadJOSN[i].fileNm)) {
                        upload_result_params2.push(uploadJOSN[i]);
                    }
                }
                console.log("upload_result_params2 =s= " + JSON.stringify(upload_result_params));

            },
        });

        $("#ownerCd").bind("change",function(e){
            var ownerCd = $("#ownerCd").val();
            console.log(ownerCd);
            if (3 == ownerCd) {
                _cfgSysCd = '${cfgSysCd3}'; //附件系统CODE
                _cfgOrgCd = '${cfgOrgCd3}'; //附件组织架构
                _tabNm = '${tabNm3}'; //附件对应表
                _cfgCd = '${cfgCd3}'; //附件CODE
                _modulePath = '${modulePath3}';
                _costomerPath = '${costomerPath3}';
                _rootPath = '${rootPath3}';
                _uploadSysCd = '${uploadSysCd3}';
            } else if(1 == ownerCd) {
                _cfgSysCd = '${cfgSysCd1}'; //附件系统CODE
                _cfgOrgCd = '${cfgOrgCd1}'; //附件组织架构
                _tabNm = '${tabNm1}'; //附件对应表
                _cfgCd = '${cfgCd1}'; //附件CODE
                _modulePath = '${modulePath1}';
                _costomerPath = '${costomerPath1}';
                _rootPath = '${rootPath1}';
                _uploadSysCd = '${uploadSysCd1}';
            } else {
                _cfgSysCd = '${cfgSysCd2}'; //附件系统CODE
                _cfgOrgCd = '${cfgOrgCd2}'; //附件组织架构
                _tabNm = '${tabNm2}'; //附件对应表
                _cfgCd = '${cfgCd2}'; //附件CODE
                _modulePath = '${modulePath2}';
                _costomerPath = '${costomerPath2}';
                _rootPath = '${rootPath2}';
                _uploadSysCd = '${uploadSysCd2}';
            }
            for (var i = 0; i < upload_result_params.length; i++) {
                upload_result_params[i].cfgCd = _cfgCd;
            }
            var rows = lnkFileInfoCfgGrid.data.rows;
            for (var i = 0; i < rows.length; i++) {
                for (var j = 0; j < allCfgDtlCdList.length; j++) {
                    if (allCfgDtlCdList[j].cfgCd == _cfgCd) {
                        if (allCfgDtlCdList[j].cfgDtlCd == rows[i].cfgDtlCd) {
                            var currentRow = rows[i];
                            currentRow.isMust = allCfgDtlCdList[j].isMust;
                            lnkFileInfoCfgGrid.updateRow(rows[i], currentRow);
                            lnkFileInfoCfgGrid.reRender();
                        }
                    }
                }
            }
        })

        //2020-01-20 hewangze modify 高蕾需求 名称和统一社会信用代码只能修改其一
        $("#lnkCompNm").bind("change",function(e){
            console.log("名称已改变,禁用统一社会信用代码文本框");
            liger.get("succ").setReadonly(true);
        })

        $("#succ").bind("change",function(e){
            console.log("统一社会信用代码已改变,禁用名称文本框");
            liger.get("lnkCompNm").setReadonly(true);
        })
    });

    //删除文件
    function delFile(event,_fileId, rowIndex){
        top.$.ligerDialog.confirm("确认删除吗?", function (flag) {
            if(!flag){
                return;
            }else{
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {'fileId':_fileId},
                    url: '<%=path%>/product/splInfo/removeFile.do',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            var row = lnkFileInfoCfgGrid.getRow(rowIndex);

                            for (var i=0; i< upload_result_params.length; i++){
                                if(upload_result_params[i].cfgDtlCd == row.cfgDtlCd && upload_result_params[i].filePath == row.filePath){
                                    console.log("cfgDtlCd =j= " + row.cfgDtlCd);
                                    upload_result_params.splice(i,1);
                                    break;
                                }
                            }

                            var gridData = lnkFileInfoCfgGrid.getData();
                            var count = 0;

                            for (var i = 0; i < gridData.length; i++) {
                                if (gridData[i].datNm == row.datNm) {
                                    count ++;
                                }
                            }

                            if (count <= 1) {
                                lnkFileInfoCfgGrid.updateCell("filePath",'',rowIndex);
                                lnkFileInfoCfgGrid.updateCell("fileNm",'',rowIndex);
                                lnkFileInfoCfgGrid.updateCell("crtTm",'',rowIndex);
                                lnkFileInfoCfgGrid.updateCell("audStsCdNm",'未验证',rowIndex);
                            } else {
                                lnkFileInfoCfgGrid.deleteRow(rowIndex);
                            }

                            console.log("upload_result_params =k= " + JSON.stringify(upload_result_params));
                        }else{
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            }
        });
    }

    function onChangefile_multi(e,cfgCd,cfgDtlCd,orgCd) {
        console.log("e == " + JSON.stringify(e));
        var wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
        var filePath= _modulePath; //之前无 '/'
        console.log("filePath ==="+filePath);

        var gridRows = lnkFileInfoCfgGrid.data.rows;
        var count = 1;
        var row ;
        for (var i = 0; i < gridRows.length; i++) {
            if (gridRows[i].cfgDtlCd == cfgDtlCd) {
                row = gridRows[i];
                break;
            }
        }
        for (var i = 0; i < gridRows.length; i++) {
            if (gridRows[i].cfgDtlCd == cfgDtlCd && StringUtils.isNotEmpty(gridRows[i].fileNm)) {
                count ++;
            }
        }
        if (row) {
            if (row.maxNum != 0 && row.maxNum < count) {
                $.ligerDialog.SQalert({content: row.datNm + "最多可上传" + row.maxNum + "份",
                    SQ_showButtons: true,SQ_type: "warning",SQ_onBtnclick:function(){console.log(row.datNm + "最多可上传" + row.maxNum + "份")}});
                wait_dialog.close();
                return ;
            }
        } else {
            $.ligerDialog.SQalert({content: "请刷新页面重试!",
                SQ_showButtons: true,SQ_type: "warning",SQ_onBtnclick:function(){console.log("没有获取到行对象[row]")}});
            wait_dialog.close();
            return ;
        }

        $.ajaxFileUpload({
            url: '<%=path%>/system/sysulfilesrec/upload.do',
            secureuri: false,
            fileElementId: e.target.id,  //这里不在是以前的id了，要写成数组的形式！
            dataType: 'json',
            data: {filePath: filePath,costomerPath:_costomerPath,rootPath:_rootPath,uploadSysCd:_uploadSysCd},
            success: function (msg) {
                if (msg.success == 1) {
                    //var row = lnkFileInfoCfgGrid.getRow(rowIndex);
                    console.log(row);

                    var uploadJOSN = JSON.parse(JSON.stringify(msg.data));
                    console.log("uploadJOSN =s= " + JSON.stringify(uploadJOSN));
                    for (var i=0; i< uploadJOSN.length; i++){
                        var oldPath = "";
                        oldPath = uploadJOSN[i].filePath;
                        if (StringUtils.isEmpty(row.fileNm)) {
                            lnkFileInfoCfgGrid.updateCell("filePath",oldPath,row.__index);
                            lnkFileInfoCfgGrid.updateCell("fileNm",uploadJOSN[i].fileNm,row.__index);
                            lnkFileInfoCfgGrid.updateCell("cfgDtlCd",cfgDtlCd,row.__index);
                            lnkFileInfoCfgGrid.updateCell("crtTm",new Date(),row.__index);
                        } else {
                            var datNm = row.datNm;
                            if (row.isMust == 1) {
                                //datNm += '<span class="requiredSymbol">*</span>';
                            }
                            lnkFileInfoCfgGrid.addRow({
                                audStsCd : 0,
                                audStsCdNm : "未验证",
                                cfgDtlCd : cfgDtlCd,
                                datNm : datNm,
                                isMust : row.isMust,
                                filePath : oldPath,
                                fileNm : uploadJOSN[i].fileNm,
                                crtTm : new Date(),
                            }, row, false)
                        }
                        uploadJOSN[i].cfgCd = _cfgCd ;
                        uploadJOSN[i].cfgDtlCd = cfgDtlCd;
                        uploadJOSN[i].orgCd = _cfgOrgCd;
                        uploadJOSN[i].tabNm = _tabNm;
                        uploadJOSN[i].sysCd = _cfgSysCd;
                        upload_result_params.push(uploadJOSN[i]);
                        console.log("upload_result_params =s= " + JSON.stringify(upload_result_params));
                        console.log("file_btn_val => " + $('#fileup_' + cfgCd + '_' + cfgDtlCd).val());
                        $('#fileup_' + cfgCd + '_' + cfgDtlCd).val('');
                        console.log("file_btn_val => " + $('#fileup_' + cfgCd + '_' + cfgDtlCd).val());
                    }
                    wait_dialog.close();
                } else {
                    wait_dialog.close();
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    };

    //删除文件
    function delUpLoadindFile(event,rowIndex,cfgDtlCd){
        top.$.ligerDialog.confirm("确认删除吗?", function (flag) {
            if(!flag){
                return;
            }else{
                var wait_dialog;
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});

                var row = lnkFileInfoCfgGrid.getRow(rowIndex);

                for (var i=0; i< upload_result_params.length; i++){
                    if(upload_result_params[i].cfgDtlCd == cfgDtlCd && upload_result_params[i].filePath == row.filePath){
                        console.log("cfgDtlCd =j= " + cfgDtlCd);
                        upload_result_params.splice(i,1);
                        break;
                    }
                }

                var gridData = lnkFileInfoCfgGrid.getData();
                var count = 0;

                for (var i = 0; i < gridData.length; i++) {
                    if (gridData[i].datNm == row.datNm) {
                        count ++;
                    }
                }

                if (count <= 1) {
                    lnkFileInfoCfgGrid.updateCell("filePath",'',rowIndex);
                    lnkFileInfoCfgGrid.updateCell("fileNm",'',rowIndex);
                    lnkFileInfoCfgGrid.updateCell("crtTm",'',rowIndex);
                } else {
                    lnkFileInfoCfgGrid.deleteRow(rowIndex);
                }
                console.log("upload_result_params =k= " + JSON.stringify(upload_result_params));
                wait_dialog.close();
            }
        });
    }

    //修改资料的验证状态
    function modifyAudStsCd(event,_fileId,_audStsCd){
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {'fileId':_fileId,'audStsCd':_audStsCd},
            url: '<%=path%>/product/splInfo/modifyFileAudStsCd.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    //$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    event.stopPropagation();
                    var gridID = $(event.target).parents('.sq-grid').attr('ligeruiid');
                    liger.get(gridID).reload();
                }else{
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }

    function downloadSplFileByUrl() {
        var data = lnkFileInfoCfgGrid.getData();
        //var files = [];
        var ids = [];
        for (var i = 0; i < data.length; i++) {
            var map = {};
            if(StringUtils.isNotEmpty(data[i].fileId)){
                ids.push(data[i].fileId);
            }
        }
        var actoinURL = '<%=path%>/system/sysulfilesrec/zipDownloadById.do?';
        var form = $("<form>");
        $('body').append(form);
        form.attr('style','display:none');
        form.attr('target','');
        form.attr('method','post');
        form.attr('action',actoinURL);//下载文件的请求路径
        var input = $('<input>');
        input.attr('type','hidden');
        input.attr('name','ids');
        input.attr('value',JSON.stringify(ids));
        form.append(input);
        form.submit();
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value && ''!= value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    function uploadFileByUrl(_url,_name){
        if(SQ.regs.img.test(_name)){
            //SQ.imgPreview(_url);
            //SQ.imgPreview(_url, true);
            window.__ImgSrc = _url;
            window.__ImgTit = _name;
            window.open('<%=path%>/project/prjbscinfo/imgWinOpen.do', '', 'location=yes, width=800, height=600');
        }else{
            window.open(_url);
        }
    }

    function relationshipsView() {
        var org_cd = $("#succ").val();
        var lnkCompId = $("#lnkCompId").val();
        var currentUserId = '${currentUserId}'
        if (!org_cd) {
            $.ligerDialog.SQalert({content: "社会同一信用代码为空！", SQ_type: "warning"});
            return false;
        }
        Add_navTab('tab_relationships_view_data' + lnkCompId + '1', '集团关联图谱', '<%=path%>/knowledgeGraph/init/initGraphGroupPage.do?org_code=' + org_cd+'&usrId='+currentUserId);
    }


    function readInfo(){
    	//alert();
    	$("#YJDQQYXXBtn").attr("disabled", "disabled");
    	$('#YJDQQYXXBtn').css("background-image","-webkit-linear-gradient(top, #999, #999)");
    	
        var lnkCompNm = $("#lnkCompNm").val();
        var url = '<%=path%>/spl/splCommBasic/getByDataId.do';
        var data = {};
        data.dataId = $("#lnkCompId").val();
        data.type = 3;
        data.dataNm = lnkCompNm;
    	$.ajax({
            type: 'get',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function(){
		          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
            success: function (msg) {
            	wait_dialog.close();
                if (msg.success == 1) {
                	top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    if (msg.data) {
                    	//console.log(msg.data);
                    	$("#succ").val(msg.data.creditcode);
                    	$("#compTyp").val(msg.data.enttype);
                    	$("#regAddr").val(msg.data.address);
                    	$("#regDt").val(msg.data.opendate);
                    	$("#bizScope").val(msg.data.busiscope1);
                    }
                } else {
                	top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "warning"});
                }
            }
        });
    }
    
    function readManagerInfo(){
    	//alert();
    	$("#YJDQGGXXBtn").attr("disabled", "disabled");
    	$('#YJDQGGXXBtn').css("background-image","-webkit-linear-gradient(top, #999, #999)");
    	
        var lnkCompNm = $("#lnkCompNm").val();
        var _id = $("#lnkCompId").val();
        var url = '<%=path%>/product/splInfo/getHolderAndMgrperson.do';
        var data = {};
        data.dataId = _id;
        //data.dataId = 17315;
        data.type = 3;
        //data.type = 2;
        data.dataNm = lnkCompNm;
        var wait_dialog;
    	$.ajax({
            type: 'get',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function(){
		          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
            success: function (msg) {
            	wait_dialog.close();
            	if(msg.success == 1){
					 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 var rlList = msg.data;
					 console.log(rlList);
					 for(psn in rlList){
						 rlPsnGrid.addRow({
				        		rlNm: rlList[psn].rlNm,
				        		rlTypCdNm: rlList[psn].rlTypCdNm,
				        		rlTypCd:rlList[psn].rlTypCd,
				        		tel: rlList[psn].tel,
				        		certTypCd: rlList[psn].certTypCd,
				        		certNo: rlList[psn].certNo,
				        		rlRem: rlList[psn].rlRem,
				        		stockRatio: rlList[psn].stockRatio
				            });
					 }
				 }else{
					 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
            }
        });
    }

    function initStyle() {
        if (BuOrgCd == "00000005") {
            $("span[isShow='iscar']").each(function () {
                $("input[isShow='iscar']").each(function () {
                    $(this).attr("validate", "{required:true}");
                });
                $(this).show();
            });
            $("span[isShow='isother']").each(function () {
                $("input[isShow='isother']").each(function () {
                    $(this).attr("validate", "");
                });
                $(this).hide();
            });
            $("div[rlPsnDiv='zk'] div input").each(function () {
                $(this).attr("validate", "");
            });
            $("div[rlPsnDiv='zk']").each(function () {
                $(this).hide();
            });
        } else {
            $("span[isShow='iscar']").each(function () {
                $("input[isShow='iscar']").each(function () {
                    $(this).attr("validate", "");
                });
                $(this).hide();
            });
            $("span[isShow='isother']").each(function () {
                $("input[isShow='isother']").each(function () {
                    $(this).attr("validate", "{required:true}");
                });
                $(this).show();
            });
        }
        if (BuOrgCd != "00000005") {
            if (audStsCd == FlowConstant.FLOW_CHECK_STATE_PASS) {
                $("#prj_lnk_comp_form div div div input").each(function () {
                    $(this).attr("readonly", "readonly");
                });
                $("#fileDetail").hide();
            } else {
                $("div[rlPsnDiv='zk']").each(function () {
                    $(this).hide();
                });
            }
            $("div[rlPsnDiv='zk'] div input").each(function () {
                $(this).attr("validate", "");
            });
            var compId = $("#lnkCompId").val();
            if (!compId) {
                //$("#lnkCompNm").removeAttr("readonly");
                $("#orgCode").removeAttr("readonly");
                //$("#bizLicNo").removeAttr("readonly");
                $("#taxRegNo").removeAttr("readonly");
            } else {
                $("#lnkCompNm").removeAttr("readonly");
                $("#orgCode").attr("readonly", "readonly");
                //$("#bizLicNo").attr("readonly", "readonly");
                $("#taxRegNo").attr("readonly", "readonly");
            }
        }
    /*     if(BuOrgCd==ProjectConstant.CODE_BU_ORG_CD_XNY){
        	$("#psnDiv").hide();
        }else{ */
        $("#psnDiv").show();
        //}

        var _suppLnkPrjTypCdListJson = ${suppLnkPrjTypCdListJson};
        $("#suppLnkPrjTypCd").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
            data: _suppLnkPrjTypCdListJson,
            valueField: 'key',
            textField:'value'
        });

        //禁用省市
        disabledRgnProvCd();
        disabledRgnCityCd();
    }

    var pageInTab = null;
    var loadedTabs = []

    //初始化数据
    function initData() {

        setFormatDateValue();
        setFormatRgnValue();
        
        $("#reasonFromSet").ligerForm({
            validate: true
        });
        $("#prj_lnk_comp_form").ligerForm({
            validate: true
        });
        var id = $("#lnkCompId").val();
        if (!id) {
            var baseForm1 = liger.get("prj_lnk_comp_form");
            baseForm1.setData({
                ownerCd: ProjectConstant.CODE_OWNER_CD
            });
            //设置公司归属默认为第三方
        }
        var form = liger.get("prj_lnk_comp_form");
        
        //设置三方授权书回显
    	var _isUploadLoa = '${prjLnkComp.isUploadLoa}';
    	var _isRecycleLoa = '${prjLnkComp.isRecycleLoa}' ;
    	if(_isUploadLoa){
    		form.setData({
        		isUploadLoa:_isUploadLoa,
        	})
    	}
    	if(_isRecycleLoa){
    		form.setData({
        		isRecycleLoa:_isRecycleLoa
        	})
    	}
    	
    	$("#isUploadLoa").val(_isUploadLoa);
    	$("#isRecycleLoa").val(_isRecycleLoa);
        initTab();
        
        if (BuOrgCd != "00000005") {
            if (audStsCd == FlowConstant.FLOW_CHECK_STATE_PASS) {
                liger.get("regDt").setDisabled(true);
                liger.get("expDt").setDisabled(true);
                liger.get("ownerCd").setDisabled(true);
                $("#rem").setDisabled_ligerTextarea(true);
            }
            pageInTab.removeTabItem("tabC");
        } else {
            pageInTab.removeTabItem("tabD");
        }

        var suppLnkPrjTypCd = '${prjLnkComp.suppPrjTypCd}';
        console.log(suppLnkPrjTypCd);
        if (suppLnkPrjTypCd) {
            $("#suppLnkPrjTypCd").ligerGetComboBoxManager().selectValue(suppLnkPrjTypCd);
            $("#suppLnkPrjTypCd").ligerGetComboBoxManager().updateStyle();
        } else {
            var defaultSuppLnkPrjTypCdString = '${defaultSuppLnkPrjTypCdString}';
            $("#suppLnkPrjTypCd").ligerGetComboBoxManager().selectValue(defaultSuppLnkPrjTypCdString);
            $("#suppLnkPrjTypCd").ligerGetComboBoxManager().updateStyle();
        }

    }

    //初始化Tab
    function initTab() {
    	
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function (tabid) {
            	
                var lnkCompId = $("#lnkCompId").val();
                if (tabid != "tabA") {
                    if (lnkCompId == null || lnkCompId == '') {
                        top.$.ligerDialog.SQalert({content: LogUtils.LOG_LNK_COMP_SELECT_BEFORE, SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function (tabid) {
                //   if (loadedTabs.indexOf(tabid)<0) {
                var lnkCompId = $("#lnkCompId").val();
                
                if (tabid != "tabA") {
                    if (lnkCompId == null || lnkCompId == '') {
                        top.$.ligerDialog.SQalert({content: LogUtils.LOG_LNK_COMP_SELECT_BEFORE, SQ_type: "warning"});
                        return false; //验证不通过，不执行以下代码
                    }
                }
                loadedTabs.push(tabid);
                
                switch (tabid) {
                    case "tabB":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjbscinfo/toPrjBscInfoListPage.do?lnkCompId=" + lnkCompId + "&&isLnkCompFlag=1");
                        break;
                    case "tabC":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjLnkCompBkAcc/toListPage.do?compId=" + lnkCompId);
                        break;
                    case "tabD":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjLnkCompCrLim/toListPage.do?compId=" + lnkCompId);
                        break;
                    case "tabE":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstManualRelation/toListPage.do?Id=" + lnkCompId +"&useType=3&cstType=2");
                        break;
                    case "tabG":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjlnkcomp/toOldFilesListPage.do?id=" + lnkCompId);
                        break;
                    case "tabF":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjlnkcomp/toThreeDataPage.do?lnkId=" + lnkCompId + "&saveBizFlowRl=" + '${saveBizFlowRl}' + "&isWarnCheck=" + '${isWarnCheck}' + "&warnRecId=" + '${warnRecId}' + "&isRiskWarnFlow=" + '${isRiskWarnFlow}');
                        break;
                }
                //     };
                SetIframe_height();
            }
        });

        if(LinkCrAmt==1){
        	pageInTab.selectTabItem("tabB"); 
        }
        
        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });

        if ($('#isShowThreeDataPage').length <= 0) {
            pageInTab.removeTabItem("tabF");
        }
        
    };
    
    
    function setFormatRgnValue(){
    	rgnPrCd = '${prjLnkComp.rgnPrCd}';
        rgnCyCd = '${prjLnkComp.rgnCyCd}';
        //alert(rgnPrCd)
        setRgnProvCdUpdataValue(rgnPrCd);
    	setRgnCityCdUpdataValue(rgnCyCd);
    	setRegionSelectDataChange();
    }
  //设置日期值
    function setFormatDateValue() {
    	
        var regDt = $("#regDt").val();
        var expDt = $("#expDt").val();
        if (expDt) {
            var expDate = DateUtils.formatDate(new Date(expDt), DateUtils.YYYY_MM_DD);
            $("#expDt").val(expDate);//道路运输许可证有效期
        }
        if (regDt) {
            var regDate = DateUtils.formatDate(new Date(regDt), DateUtils.YYYY_MM_DD);
            $("#regDt").val(regDate);//注册日期
        }

    }

    //检查是否重名
    function checkPrjLnkCompNm() {
        var flag = false;
        var lnkCompNm = $("#lnkCompNm").val();
        var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
        var data = {};
        data.lnkCompNm = lnkCompNm;
        if (lnkCompNm) {
            $.ajax({
                type: 'get',
                dataType: 'json',
                data: data,
                url: url,
                success: function (msg) {
                    if (msg.success == 1) {
                        if (msg.data) {
                            top.$.ligerDialog.SQalert({content: "该挂靠公司已经存在", SQ_type: "error"});
                            flag = true;
                        }
                    }
                }
            });
        }
        return flag;
    }

    //取消
    function cancelBtn() {
        var TAB = top.mainApp.parentTab;
        var currentTabid = TAB.getSelectedTabItemID();
        top.tab.removeTabItem(currentTabid);
    }

	function save(){
		var reason = $('#reason').val();
		var ligerForm = liger.get("prj_lnk_comp_form");
        var rgnPrCd = getRgnProvCd();//获取省代码
    	var rgnCyCd = getRgnCityCd();//获取市代码
    	//console.log(rgnPrCd)
    	//console.log(rgnCyCd)
        if (!ligerForm.valid()) {
        	console.log(ligerForm);
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var rlPsnData = rlPsnGrid.getData();
        var lnkCompNm = $("#lnkCompNm").val();
        var lnkCompId = $("#lnkCompId").val();
        
        if (lnkCompId) {
            var data = ligerForm.getData();
            data["regDt"] = $("#regDt").val();
            data["expDt"] = $("#expDt").val();
            
            data["isUploadLoa"] = $("#isUploadLoa").val();
            data["isRecycleLoa"] = $("#isRecycleLoa").val();
            //event.preventDefault();
            data["rgnPrCd"] = rgnPrCd;//获取省代码
    		data["rgnCyCd"] = rgnCyCd;//获取市代码

			data["reason"] = reason;// 操作原因
			
            
            var fileParams = upload_result_params;//getUploadResultParams();//获取附件上传的信息
            var checkFilesResult = checkFiles(fileParams);
            if (checkFilesResult != 1) {
                top.$.ligerDialog.SQalert({content: checkFilesResult, SQ_type: "warning"});
                return false;
            }
            data["fileParams"] = JSON.stringify(fileParams);
              if(BuOrgCd!=ProjectConstant.CODE_BU_ORG_CD_XNY){
            var isValid = SQ.validGrid('ligergrid_psn');
            if (isValid == false) {
                UIUtils.alertError("请正确填写！");
                return false;
            }
              }
            data["rlPsnList"] = JSON.stringify(rlPsnData);
            var url = '<%=path%>/project/prjlnkcomp/addPrjLnkComp.do';
            var lnkCompId = $("#lnkCompId").val();
            data["lnkCompId"] = lnkCompId;
            console.log(data)
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        /*if (!isFlow) {
                            var TAB = top.mainApp.parentTab;
                            var currentTabid = TAB.getSelectedTabItemID();
                            var currFrameElement = top.$("#" + currentTabid).get(0);*/
                            $("#lnkCompId").val(msg.data);;
                            /*if(fromSrcBiz){
                                var wcallback = GET_W2Wcallback() ;
                                if(fromSrcBiz == 'QKYW'){
                                    wcallback(msg.data,lnkCompNm);
                                }
                            }else{
                                var callback = currFrameElement.W2W.callback;
                                callback();
                            }
                            top.tab.removeTabItem(currentTabid);
                        } else {
                            lnkFileInfoCfgGrid.reload();
                        }*/
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        } else {
            var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
            var data = {};
            data.lnkCompNm = lnkCompNm;
            $.ajax({
                type: 'get',
                dataType: 'json',
                data: data,
                url: url,
                success: function (msg) {
                    if (msg.success == 1) {
                        if (msg.data) {
                            top.$.ligerDialog.SQalert({content: "该挂靠公司已经存在", SQ_type: "error"});
                            return false;
                        }
                    } else {
                        var data = ligerForm.getData();
                        data["rgnPrCd"] = rgnPrCd;//获取省代码
                    	data["rgnCyCd"] = rgnCyCd;//获取市代码
                        data["regDt"] = $("#regDt").val();
                        data["expDt"] = $("#expDt").val();
						data["importDataSource"] = importDataSource ;//数据来源

						data["reason"] = reason;// 操作原因

                        var fileParams = upload_result_params;//getUploadResultParams();//获取附件上传的信息
                        data["fileParams"] = JSON.stringify(fileParams);
                           if(BuOrgCd!=ProjectConstant.CODE_BU_ORG_CD_XNY){
                        var isValid = SQ.validGrid('ligergrid_psn');
                        if (isValid == false) {
                            UIUtils.alertError("请正确填写！");
                            return false;
                        }
                          }
                        data["rlPsnList"] = JSON.stringify(rlPsnData);
                        var url = '<%=path%>/project/prjlnkcomp/addPrjLnkComp.do';
                        var lnkCompId = $("#lnkCompId").val();
                        data["lnkCompId"] = lnkCompId;
                        var wait_dialog;
                        $.ajax({
                            type: 'post',
                            dataType: 'json',
                            data: data,
                            url: url,
                            beforeSend: function () {
                                wait_dialog = $.ligerDialog.SQalert({
                                    content: LogUtils.LOG_CMM_DATA_LOADING,
                                    SQ_type: "waitting"
                                });
                            },
                            success: function (msg) {
                                wait_dialog.close();
                                if (msg.success == 1) {
                                    $("#lnkCompId").val(msg.data);
                                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                                    var TAB = top.mainApp.parentTab;
                                    var currentTabid = TAB.getSelectedTabItemID();
                                    var currFrameElement = top.$("#" + currentTabid).get(0);
                                    if(fromSrcBiz){
                                        var wcallback = GET_W2Wcallback() ;
                                        if(fromSrcBiz == 'QKYW'){
                                            wcallback(msg.data,lnkCompNm);
                                        }
                                    }else{
                                        var callback = GET_W2Wcallback();// currFrameElement.W2W.callback;
                                        callback();
                                    }
                                    top.tab.removeTabItem(currentTabid);

                                } else {
                                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                                }
                            }
                        });
                    }
                }
            });

        }
	}

	function checkFiles(fileParams) {
        if (fileParams.length <= 0){
            return "请上传附件信息";
        }
        var rows = lnkFileInfoCfgGrid.data.rows;
        var count = {};
        for (var i = 0; i < rows.length; i++) {
            if (rows[i].isMust == 1 && StringUtils.isEmpty(rows[i].fileNm)){
                return "请上传" + rows[i].datNm;
            }
            if (rows[i].maxNum != 0 && rows[i].__status != 'delete'){
                if(count[rows[i].cfgDtlCd]){
                    count[rows[i].cfgDtlCd] += 1;
                } else {
                    count[rows[i].cfgDtlCd] = 1;
                }
            }
        }
        for (var i = 0; i < rows.length; i++) {
            if (rows[i].maxNum != 0) {
                if (rows[i].maxNum < count[rows[i].cfgDtlCd]) {
                    return rows[i].datNm + "不得多于" + rows[i].maxNum + "张";
                }
            }
        }
        return 1;
    }

    function initRlPsnGrid() {
        var _lnkCompId = $("#lnkCompId").val();
        var _audStsCd = '${isCheck}';
        if (!_lnkCompId) {
            return;
        }
        rlPsnGrid = $("#ligergrid_psn").ligerGrid({
            url: '<%=path%>/project/prjLnkCompRlPsn/initList.do?prjLnkCompId=' + _lnkCompId+'&isMask='+0,
            method: 'get',
            columns: [
                {
                    display: '姓名(<span class="c_red">*</span>)', name: 'rlNm', minWidth: 80, editor: {type: 'text'},
                    validate: function (value,rowData,col) {
                        //if (StringUtils.isEmpty(value) && CollectionUtils.isNotEmpty(mustAddRlPsnJSON) && mustAddRlPsnJSON.indexOf(rowData.rlTypCd) >= 0) return "此项为必填项！";
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {
                    display: '联系人类型(<span class="c_red">*</span>)', name: 'rlTypCdNm', minWidth: 80,
                    editor: {
                        type: 'select',
                        data: rlRsnTypListJSON,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'rlTypCd',
                    textField: 'rlTypCdNm',
                    render: function (item) {
                        return item.rlTypCdNm;
                    },
                    validate: function (value,rowData) {
                        //if (StringUtils.isEmpty(value) && CollectionUtils.isNotEmpty(mustAddRlPsnJSON) && mustAddRlPsnJSON.indexOf(rowData.rlTypCd) >= 0) return "此项为必填项！";
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
				{
                    display: '股比', name: 'stockRatio', minWidth: 80
                },
                {
                    display: '证件类型', name: 'certTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: certTypCdList,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'certTypCd',
                    textField: 'certTypCdNm',
                    render: function (item) {
                        return item.certTypCdNm;
                    },
                    validate: function (value,rowData) {
                        //if (StringUtils.isEmpty(value) && CollectionUtils.isNotEmpty(mustAddRlPsnJSON) && mustAddRlPsnJSON.indexOf(rowData.rlTypCd) >= 0) return "此项为必填项！";
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {
                    display: '证件号码',
                    name: 'certNo',
                    width: 140,
                    //align: 'left',
                    editor: {type: 'text'},
                    render: function (value,rowData) {
                        if(StringUtils.isEmpty(value.certNo)){
                            if(value.rlTypCd != 2){
                                return '<span class="c_gray">(非必填信息)</span>';
                            }else{
                                return '<span class="c_gray">(必填信息)</span>';
                            }
                        }
                        return value.certNo;
                    },
                    validate: function (value,rowData) {
                        if (StringUtils.isEmpty(value)){
                            if(rowData.rlTypCd == 2){
                                return "此项为必填项！";
                            }
                        }
                    }
                },
                {
                    display: '联系电话',
                    name: 'tel',
                    width: 100,
                    //align: 'left',
                    editor: {type: 'text'},
                    render: function (value,rowData) {
                        if(StringUtils.isEmpty(value.tel) && StringUtils.isNotEmpty(value.rlTypCd)){
                            if(value.rlTypCd != 2){
                                return '<span class="c_gray">(非必填信息)</span>';
                            }else{
                                return '<span class="c_gray">(必填信息)</span>';
                            }
                        }
                        return value.tel;
                    },
                    validate: function (value,rowData) {
                        //if (StringUtils.isEmpty(value) && CollectionUtils.isNotEmpty(mustAddRlPsnJSON) && mustAddRlPsnJSON.indexOf(rowData.rlTypCd) >= 0) return "此项为必填项！";
                        if (StringUtils.isEmpty(value)){
                            if(rowData.rlTypCd == 2){
                                return "此项为必填项！";
                            }
                        }
                    }
                },
                {display: '备注', name: 'rlRem', minWidth: 140, editor: {type: 'text'}},
                {
                    display: '工商信息校验', name: 'checkVerify', minWidth: 150,
                    render: function (rowdata, rowindex, value) {
                        var h = "";
                            if (rowdata.busInfoVerify == 2 || rowdata.busInfoVerify == null) {
                                //h += "<a  href = "javascript:checkRlPsn('Verify',\''+rowdata.id+'\',\''+rowdata.rlNm+'\',\''+rowdata.certNo+'\',\''+rowdata.tel+'\');" class = "sq-button sq-button-round">验证</a>"

                                h += '<a class="sq-button sq-button-round" href="javascript:checkRlPsn(1,\'' + rowdata.id + '\',\'' + rowdata.rlNm + '\',\'' + rowdata.certNo + '\',\'' + rowdata.tel + '\',\'' + rowdata.rlTypCd + '\');">验证</a>'
                            } else {
                                h += '<div class="sq-button sq-button-round disabled">已校验</div>'
                            }
                        return h;
                    }
                },
                {
                    display: '工商信息校验结果', name: 'busInfoVerify', minWidth: 150,
                    render: function (rowdata, rowindex, value) {
                        if (rowdata.busInfoVerify == 1) {
                            return "一致";
                        } else if (rowdata.busInfoVerify == -1) {
                            return "不一致";
                        } else if (rowdata.busInfoVerify == 0) {
                            return "未查得";
                        } else {
                            return "";
                        }
                    }
                },
                {
                    display: '三要素校验（机构1）', name: 'PYCheck', minWidth: 150,
                    render: function (rowdata, rowindex, value) {

                        var h = "";
                            if (rowdata.pyPerVerify == 2 || rowdata.pyPerVerify == null) {
                                //h += "<a  href = "javascript:checkRlPsn('Verify',\''+rowdata.id+'\',\''+rowdata.rlNm+'\',\''+rowdata.certNo+'\',\''+rowdata.tel+'\');" class = "sq-button sq-button-round">验证</a>"

                                h += '<a class="sq-button sq-button-round" href="javascript:checkRlPsn(2,\'' + rowdata.id + '\',\'' + rowdata.rlNm + '\',\'' + rowdata.certNo + '\',\'' + rowdata.tel + '\',\'' + rowdata.rlTypCd + '\');">验证</a>'
                            } else {
                                h += '<div class="sq-button sq-button-round disabled">已校验</div>'
                            }
                        return h;
                    }
                },
                {
                    display: '三要素校验结果1', name: 'pyPerVerify', minWidth: 150,
                    render: function (rowdata, rowindex, value) {
                        if (rowdata.pyPerVerify == 1) {
                            return "一致";
                        } else if (rowdata.pyPerVerify == -1) {
                            return "不一致";
                        } else if (rowdata.pyPerVerify == 0) {
                            return "未查得";
                        } else {
                            return "";
                        }
                    }
                },
                {
                    display: '三要素校验（机构2）', name: 'TDCheck', minWidth: 150,
                    render: function (rowdata, rowindex, value) {
                        var h = "";
                            if (rowdata.tdPerVerify == 2 || rowdata.tdPerVerify == null) {
                                //h += "<a  href = "javascript:checkRlPsn('Verify',\''+rowdata.id+'\',\''+rowdata.rlNm+'\',\''+rowdata.certNo+'\',\''+rowdata.tel+'\');" class = "sq-button sq-button-round">验证</a>"

                                h += '<a class="sq-button sq-button-round" href="javascript:checkRlPsn(3,\'' + rowdata.id + '\',\'' + rowdata.rlNm + '\',\'' + rowdata.certNo + '\',\'' + rowdata.tel + '\',\'' + rowdata.rlTypCd + '\');">验证</a>'
                            } else {
                                h += '<div class="sq-button sq-button-round disabled">已校验</div>'
                            }
                        return h;
                    }
                },
                {
                    display: '三要素校验结果2', name: 'tdPerVerify', minWidth: 150,
                    render: function (rowdata, rowindex, value) {
                        if (rowdata.tdPerVerify == 1) {
                            return "一致";
                        } else if (rowdata.tdPerVerify == -1) {
                            return "不一致";
                        } else if (rowdata.tdPerVerify == 0) {
                            return "未查得";
                        } else {
                            return "";
                        }
                    }
                },
                {
                    display: '三要素校验（机构3）', name: 'BRCheck', minWidth: 150,
                    render: function (rowdata, rowindex, value) {
                        var h = "";
                            if (rowdata.brPerVerify == 2 || rowdata.brPerVerify == null) {
                                //h += "<a  href = "javascript:checkRlPsn('Verify',\''+rowdata.id+'\',\''+rowdata.rlNm+'\',\''+rowdata.certNo+'\',\''+rowdata.tel+'\');" class = "sq-button sq-button-round">验证</a>"
                                h += '<a class="sq-button sq-button-round" href="javascript:checkRlPsn(4,\'' + rowdata.id + '\',\'' + rowdata.rlNm + '\',\'' + rowdata.certNo + '\',\'' + rowdata.tel + '\',\'' + rowdata.rlTypCd + '\');">验证</a>'
                            } else {
                                h += '<input class="sq-button sq-button-round disabled" type="button" value="已校验" disabled>'
                            }
                        return h;
                    }
                },
                {
                    display: '三要素校验结果3', name: 'brPerVerify', minWidth: 150,
                    render: function (rowdata, rowindex, value) {
                        if (rowdata.brPerVerify == 1) {
                            return "一致";
                        } else if (rowdata.brPerVerify == -1) {
                            return "不一致";
                        } else if (rowdata.brPerVerify == 0) {
                            return "未查得";
                        } else {
                            return "";
                        }
                    }
                },
                getOptColumn()
            ],
            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "certTypCdNm") {
                    e.record.certTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.certTypCd = e.record.certTypCdId;
                }
                if (e.selected && e.column.columnname == "rlTypCdNm") {
                    e.record.rlTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlTypCd = e.record.rlTypCdId;
                }
            },
            onBeforeEdit: function (e) {
                e.lastValue = e.value;
                e.index = e.rowindex;
                e.column.editor.readonly = false;
                var colNanme = e.column.columnname;
                if (e.record.isSysDef == 1) {
                    if (colNanme == "rlTypCdNm") {
                        e.column.editor.readonly = true;
                    }
                }
            },

            pageSize: 100,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            heightDiff: -2,
            checkbox: false,
            enabledEdit: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            rownumbers: true,
            enabledSort: false,
            usePagerOnLessPagesize: false,
        });
        rlPsnGrid.setHeight(200);
    }
    //获取操作列
    function getOptColumn() {
        var column = {
            display: '操作',
            isSort: false,
            width: 150,
            align: 'left',
            render: function (rowdata, rowindex, value) {
                var h = "";
                    h += '<a class="sq-button-hasicon" href="javascript:removeBtn(';
                    h += "'" + rowdata.id + "'";
                    h += ')"><i class="sqBtnIco_7"></i>删除</a>'
                return h;
            }
        }
        return column;
    }

    function removeBtn() {
        var selectedRows = rlPsnGrid.getSelectedRows();
        if (selectedRows.length != 1) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
            return;
        }
        $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
            if (flag == false) return;
            if (selectedRows[0].id) {
                //删除数据
                var _ids = [];
                for (var index in selectedRows) {
                    _ids.push(selectedRows[index].id);
                }
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids: JSON.stringify(_ids)},
                    url: '<%=path%>/project/prjLnkCompRlPsn/removeByIds.do',
                    success: function (msg) {
                        if (msg.success == 1) {
                            rlPsnGrid.deleteSelectedRow();
                            rlPsnGrid.reload();
                            UIUtils.alertSuccess(msg.info);
                        } else {
                            UIUtils.alertError(msg.info);
                        }
                    }
                });

            } else {
                rlPsnGrid.deleteSelectedRow();
            }
        });
    }
    function checkRlPsn(type, dataId, rlNm, certNo, tel, rlTypCd) {
        var _type;
        if (type == 1) {
            _type = 'verify';
        }
        if (type == 2) {
            _type = 'PY';
        }
        if (type == 3) {
            _type = 'TD';
        }
        if (type == 4) {
            _type = 'BR';
        }
        var _lnkCompId = $("#lnkCompId").val();
        var _url = '<%=path%>/project/prjLnkCompRlPsn/checkRlPsn.do';
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {
                type: _type,
                dataId: dataId,
                rlNm: rlNm,
                certNo: certNo,
                tel: tel,
                compId: _lnkCompId
            },
            url: _url,
            success: function (msg) {
                if (msg.success == 1) {
                    //alert(msg.info)
                    initRlPsnGrid();

                } else {
                    //$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    initRlPsnGrid();
                }
            }
        });
    }

    function initRlPsnCarGrid(data) {
        rlPsnGrid = $("#ligergrid_psn").ligerGrid({
            data: data,
            columns: [
                {display: '姓名(<span class="c_red">*</span>)', name: 'rlNm', minWidth: 60, editor: {type: 'text'}},
                {
                    display: '联系人类型(<span class="c_red">*</span>)', name: 'rlTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: rlRsnTypListJSON,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'rlTypCd',
                    textField: 'rlTypCdNm',
                    render: function (item) {
                        return item.rlTypCdNm;
                    },
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {
                    display: '证件类型(<span class="c_red">*</span>)', name: 'certTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: certTypCdList,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'certTypCd',
                    textField: 'certTypCdNm',
                    render: function (item) {
                        return item.certTypCdNm;
                    },
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {
                    display: '证件号码(<span class="c_red">*</span>)',
                    name: 'certNo',
                    width: 140,
                    align: 'left',
                    editor: {type: 'text'}
                },
                {
                    display: '联系电话(<span class="c_red">*</span>)',
                    name: 'tel',
                    width: 100,
                    align: 'left',
                    editor: {type: 'text'},
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {display: '备注', name: 'rlRem', minWidth: 140, editor: {type: 'text'}},
            ],
            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "certTypCdNm") {
                    e.record.certTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.certTypCd = e.record.certTypCdId;
                }
                if (e.selected && e.column.columnname == "rlTypCdNm") {
                    e.record.rlTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlTypCd = e.record.rlTypCdId;
                }
            },
            onBeforeEdit: function (e) {
                e.lastValue = e.value;
                e.index = e.rowindex;
                e.column.editor.readonly = false;
                var colNanme = e.column.columnname;
                if (e.record.isSysDef == 1) {
                    if (colNanme == "rlTypCdNm") {
                        e.column.editor.readonly = true;
                    }
                }
            },
            pageSize: 100,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            heightDiff: -2,
            checkbox: false,
            enabledEdit: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            rownumbers: true,
            enabledSort: false,
            usePagerOnLessPagesize: false,
        });
        rlPsnGrid.setHeight(200);
    }

</script>
</body>
</html>